#include <iostream>

// 基本原则
// 复制函数（拷贝构造函数和拷贝赋值运算符）应该复制对象的所有成员变量
// 如果是派生类，还要复制基类部分

class Customer
{
public:
    Customer(){}
    Customer(const Customer &rhs);
    Customer &operator=(const Customer &rhs);

private:
    std::string name;
    std::string address;
    int customerID;
};

// 错误的拷贝构造函数实现，遗漏customerID

Customer::Customer(const Customer &rhs): name(rhs.name), address(rhs.address)
{

}
// 错误的赋值运算符实现 - 遗漏了address
Customer& Customer::operator=(const Customer& rhs) {
    name = rhs.name;
    customerID = rhs.customerID;
    return *this;
} // 忘记复制address！


// 处理继承的情况
class PriorityCustomer : public Customer
{
public:
    //错误的拷贝构造函数，未复制基类部分
    PriorityCustomer(const PriorityCustomer& rhs): priority(rhs.priority){}

    //错误的拷贝构造函数，未复制基类部分

    PriorityCustomer& operator=(const PriorityCustomer&rhs)
    {
        priority = rhs.priority;
        return *this;
    }

private:
    int priority;
};

//正确的实现
class PriorityCustomer_ : public Customer
{
public:
    //错误的拷贝构造函数，未复制基类部分
    PriorityCustomer_(const PriorityCustomer_& rhs):
    Customer(rhs), priority(rhs.priority)
     {}

    //错误的拷贝构造函数，未复制基类部分

    PriorityCustomer_& operator=(const PriorityCustomer_&rhs)
    {
        Customer::operator=(rhs);
        priority = rhs.priority;
        return *this;
    }

private:
    int priority;
};